package dk.hewison.client.mvc.widgets;

import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.Button;
import dk.hewison.client.mvc.Action;
import dk.hewison.client.mvc.NetlWidget;

/**
 * @author John Hewison
 * @author $LastChangedBy: john.hewison $:  $ $LastChangedDate: 2009-02-01 11:47:49 +0000 (Sun, 01 Feb 2009) $:
 * @version $Revision: 62 $:
 */
public class MButton extends Button implements NetlWidget {

    private Action action;

    public MButton(final Action action) {
        action.addNetlWidget(this);
        this.action = action;
        addClickListener(new ClickListener() {
            public void onClick(Widget sender) {
                action.execute();
            }
        });
        action.addNetlWidget(this);
    }

    public Action getAction() {
        return action;
    }

    @Override
    public void setEnabled(boolean enabled) {
        if (this.isEnabled() != enabled) {
            super.setEnabled(enabled);
        }
    }

}
